﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UTL.Hasher;

namespace TST
{
    public partial class FrmCode : Form
    {
        public FrmCode()
        {
            InitializeComponent();
        }

        private void cmdEncode_Click(object sender, EventArgs e)
        {
            // First get the bytes for the original
            byte[] data = UnicodeEncoding.UTF8.GetBytes(txtDecode.Text);
            Base64Encoder myEncoder = new Base64Encoder(data);
            StringBuilder sb = new StringBuilder();

            sb.Append(myEncoder.GetEncoded());

            txtEncode.Text = sb.ToString();
        }

        private void cmdDecode_Click(object sender, EventArgs e)
        {
            char[] data = txtEncode.Text.ToCharArray();
            Base64Decoder myDecoder = new Base64Decoder(data);
            StringBuilder sb = new StringBuilder();

            byte[] temp = myDecoder.GetDecoded();
            sb.Append(UTF8Encoding.UTF8.GetChars(temp));

            txtDecode.Text = sb.ToString();
        }
    }
}